package tw.com.jinwei;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.apache.log4j.Logger;

import tw.com.jinwei.ui.MainFrame;
import tw.com.jinwei.utils.ContextUtils;
import tw.com.jinwei.utils.LogHelper;

public class Application extends org.jdesktop.application.Application {

	private Logger log = LogHelper.getLog(getClass());
	MainFrame mainFrame;

	@Override
	protected void startup() {
		if (log.isDebugEnabled()) {
			log.debug(new StringBuilder("application startup"));
		}

//		SwingUtilities.invokeLater(new Runnable() {
//
//			public void run() {
//				try {
//					// Set cross-platform Java L&F (also called "Metal")
//					UIManager
//							.setLookAndFeel("org.pushingpixels.substance.api.skin.SubstanceBusinessLookAndFeel");
//				} catch (UnsupportedLookAndFeelException e) {
//					// handle exception
//				} catch (ClassNotFoundException e) {
//					// handle exception
//				} catch (InstantiationException e) {
//					// handle exception
//				} catch (IllegalAccessException e) {
//					// handle exception
//				}
//
//				mainFrame = (MainFrame) ContextUtils.getContext().getBean(
//						"mainFrame");
//				mainFrame.initMenuBar();
//				mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
//				mainFrame.setVisible(true);
//			}
//		});

		System.setProperty("Quaqua.tabLayoutPolicy", "wrap");
		// set the Quaqua Look and Feel in the UIManager
		try {
			UIManager.setLookAndFeel(ch.randelshofer.quaqua.QuaquaManager
					.getLookAndFeel());
			// set UI manager properties here that affect Quaqua
		} catch (Exception e) {
			// take an appropriate action here
		}
		
		mainFrame = (MainFrame) ContextUtils.getContext().getBean("mainFrame");
		mainFrame.initMenuBar();
		mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
		mainFrame.setVisible(true);
	}

}
